import { Component, Input, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { Location } from '@angular/common';
import { UserService} from "./user.service";
import { User } from "./user";

@Component({
  selector: "details-nav",
  templateUrl: './details.component.html',
  styleUrls: [ "./details.component.css" ]
})
export class DetailsComponent implements OnInit{
  @Input() back: string;
  @Input() title: string;
  user: User
  constructor(
    private userService: UserService,
    private router: Router,
    private location: Location) { }

  ngOnInit(): void {
    this.userService.getUserMine().then(user => this.user = user)
  }

  goBack(): void {
    if (this.back)
      this.router.navigate([ this.back ]);
    else
      this.location.back();
  }
}
